home *** CD-ROM | disk | FTP | other *** search
-
- #ifndef __SCENERENDERER_H_
- #define __SCENERENDERER_H_
- /*
- Peon - Win32 Games Programming Library
- Copyright (C) 2002-2005 Erik Yuzwa
-
- This library is free software; you can redistribute it and/or
- modify it under the terms of the GNU Library General Public
- License as published by the Free Software Foundation; either
- version 2 of the License, or (at your option) any later version.
-
- This library is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- Library General Public License for more details.
-
- You should have received a copy of the GNU Library General Public
- License along with this library; if not, write to the Free
- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
- Erik Yuzwa
- peon AT wazooinc DOT com
- */
-
-
- #include "IUnknown.h"
- #include "PrimTypes.h"
- #include "SceneCamera.h"
- #include "SceneLight.h"
- #include "SceneTexture.h"
- #include "SceneFont.h"
- #include "Matrix44.h"
-
- /** our maximum lights allowed at one time in our engine. OpenGL allows
- * 7 if I remember right, and Direct3D allows something similar. New hardware
- * might blow these boundaries away through shaders, but let's pretend you
- * can only use 7
- */
- #define MAX_LIGHTS 7
-
- namespace peon
- {
- /**
- * This object is responsible for processing our rendering commands
- * to the underlying video hardware. Rather than spread a whole bunch
- * of API specific code in our actual game, it'd be nice to just command
- * this object to do the work for us.
- */
- class PEONMAIN_API SceneRenderer : public IUnknown
- {
- protected:
- /** OpenGL rendering surface */
- SDL_Surface* m_pOGLSurface;
-
- /** surface width */
- int m_iDeviceWidth;
-
- /** surface height */
- int m_iDeviceHeight;
-
- /** surface bits-per-pixel */
- int m_iBitsPerPixel;
-
- /** windowed or fullscreen? */
- bool m_bWindowed;
-
- /** our current SceneCamera object */
- SceneCamera* m_pActiveCamera;
-
- /** an array of SceneLight objects. */
- SceneLight m_oLights[MAX_LIGHTS];
-
- public:
- /**
- * Constructor
- */
- SceneRenderer();
-
- /**
- * Destructor
- */
- ~SceneRenderer();
-
- /**
- * This method loads our configuration settings in order to prepare
- * our rendering context
- * @param pConfig - IniConfigReader object
- * @return bool - true or false
- */
- bool loadDevice( IniConfigReader* pConfig );
-
- /**
- * This method deallocated and cleans up our surfaces
- */
- void unloadDevice();
-
- /**
- * This method clears the back buffer and prepares it for us
- * to send rendering commands to
- * @return bool - always true
- */
- bool clearDevice();
-
- /**
- * This method is responsible for swapping our back buffer with
- * the front one...thereby rendering a new screen
- */
- void flipDevice();
-
- /**
- * This method takes in an array of vertices and renders them to
- * our context
- * @param pVertices - array of DiffusePrim objects
- * @param count - count of DiffusePrim objects in array
- */
- void drawPrim( DiffusePrim* pVertices, int count );
-
- /**
- * This method takes in an array of vertices and renders them to
- * our context
- * @param pVertices - array of DiffuseTexPrim objects
- * @param count - count of DiffuseTexPrim objects in array
- */
- void drawPrim( DiffuseTexPrim* pVertices, int count );
-
- /**
- * This method takes in an array of vertices and renders them to
- * our context
- * @param pVertices - array of NormalDiffuseTexPrim objects
- * @param count - count of NormalDiffuseTexPrim objects in array
- */
- void drawPrim( NormalDiffuseTexPrim* pVertices, int count );
-
- /**
- * This method takes in an array of vertices and renders them to
- * our context
- * @param pVertices - array of NormalDiffuseTexPrim objects
- * @param count - count of NormalDiffuseTexPrim objects in array
- */
- void drawQuads( NormalDiffuseTexPrim* pVertices, int count );
-
- /**
- * This method simply sets a set of lighting states within our
- * scene depending upon the parameters
- * @param light_slot - which slot we wish to affect
- * @param oLight - our SceneLight object
- */
- void setLight(int light_slot, const SceneLight& oLight);
-
- /**
- * This method is responsible for loading an image into
- * the texture memory of your device
- * @param strFilename - the path to the image file
- * @param bAlpha - do we have an alpha channel?
- * @param bMipMaps - do we create mipmaps?
- * @param bRepeat - do we repeat the texture?
- * @return SceneTexture* - pointer to the created SceneTexture object
- */
- SceneTexture* loadTexture( const String& strFilename, bool bAlpha = true,
- bool bMipMaps = true, bool bRepeat = false);
-
- /**
- * This method just informs the renderer to make this texture the
- * currently active one
- * @param pTex - pointer to our SceneTexture handle
- */
- //void setTexture( SceneTexture* pTex );
-
- /**
- * This method is responsible for loading a font object into a
- * SceneFont handle
- * @param char_width - pixel width of each character
- * @param char_height - pixel height of each character
- * @param char_spacing - spacing in pixels between character
- * @return SceneFont* - handle to our created SceneFont
- */
- SceneFont* loadFont( int char_width = 16, int char_height = 16, int char_spacing = 10 );
-
- /**
- * This method just returns our active camera
- * @return SceneCamera* - handle to our SceneCamera
- */
- SceneCamera* getActiveCamera(){ return m_pActiveCamera; }
-
- /**
- * Gets the width of our device
- * @return int - device width
- */
- int getWidth(){ return m_iDeviceWidth; }
-
- /**
- * Gets the height of our device
- * @return int - device height
- */
- int getHeight(){ return m_iDeviceHeight; }
-
- /**
- * Check to see if an extension is supported
- * @param strExtension - string object containing extension name
- * @return bool - true if it does, false otherwise
- */
- bool isExtensionSupported( const String& strExtension );
-
- /**
- * This method is responsible for taking screen captures
- */
- void getScreenCapture();
-
- /**
- * This method simply fills a Matrix44 object with the current
- * projection matrix
- * @param pMat - handle to our Matrix44 object
- */
- void getProjectionMatrix( Matrix44& pMat );
-
- /**
- * This method simply fills a Matrix44 object with the current
- * modelview matrix
- * @param pMat - handle to our Matrix44 object
- */
- void getModelViewMatrix( Matrix44& pMat );
-
- };
- }
-
- #endif
-